package joc.contract;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class AnnotationInstantiator {
	@SuppressWarnings("unchecked")
	public static <T> T getProxySingleValue(Class<T> annotationClass, final Object returnValue) {
		return (T) Proxy.newProxyInstance(annotationClass.getClassLoader(), new Class[] { annotationClass }, new InvocationHandler() {
			@Override
			public Object invoke(Object obj, Method method, Object[] args)
					throws Throwable {
				return returnValue;
			}
		});
	}

	public static <T> T getProxyNoValue(Class<T> annotationClass) {
		return AnnotationInstantiator.getProxySingleValue(annotationClass, null);
	}
}
